// --------基本信息------------------------------------------------------------------------------------------------
//编辑基本信息
function editorBasic(){
	mainCon.find('.basicInfoCon').hide();
	mainCon.find('.basicInfoInput').show();
	//上传头像
	mainCon.find('.basicInfo').find('.basicInfoInput').find('.frame').hover(function(){
		$(this).find('.editavatar').show();
	}, function(){
		$(this).find('.editavatar').hide();
	});
	uploadAvatar("#upavatar", '#avatar');


	//jsoninput赋值
	jsonBasic();
	//个人简历手机号码验证
	$.validator.addMethod("checkMobile", function(value, element, param){
		var regu = /(^1[3-9]{1}[0-9]{9}$)/g;
		if(regu.test(value)){
			return true;
		}else{
			return false;
		}
	}, "请输入正确的手机号码");
	//请输入正确的身高
	$.validator.addMethod("checkHeight", function(value, element, param){
		if(value != ''){
			var regu = /(^[0-9]{2,3})$/g;
			if(regu.test(value)){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}, "请输入正确的身高");
	//个人QQ号码验证
	$.validator.addMethod("checkQQ", function(value, element, param){
		if(value != ''){
			var regu = /(^[1-9]{1}[0-9]{4,15})$/g;
			if(regu.test(value)){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}, "请输入正确的QQ号码");

	//个人简历表单验证 使用jQuery Validate 插件进行验证
	$('#basicForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			name: {
				required: true
			},
			sex: {
				required: true
			},
			birthday: {
				required: true
			},
			homeaddress: {
				required: true
			},
			job_status: {
				required: true
			},
			education: {
				required: true
			},
			height: {
				checkHeight: true                            //期望的是true,如果为false则展示提示信息
			},
			mobile: {
				required: true,
				minlength: 11,
				checkMobile: true //期望的是true,如果为false则展示提示信息
			},
			email: {
				email: true
			},
			qq: {
				checkQQ: true                            //期望的是true,如果为false则展示提示信息
			}
		},
		//错误信息提示修改
		messages: {
			name: {
				required: "请输入姓名"
			},
			sex: {
				required: "请选择性别"
			},
			birthday: {
				required: "请选择出生年月"
			},
			homeaddress: {
				required: "请选择现居地"
			},
			job_status: {
				required: "请选择求职状态"
			},
			education: {
				required: "请选择最高学历"
			},
			mobile: {
				required: "请输入手机号码",
				minlength: "手机号码长度必须是11位数字"
			},
			email: {
				email: "请输入一个正确的邮箱"
			}
		},

		submitHandler: function(form){
			var queryString = $('#basicForm').formSerialize();
			$.ajax({
				url: '/personal/resume_basic',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#basicForm').find('#save').val('请稍候');
					$('#basicForm').find('#save').attr('disabled', true);
					$('#basicForm').find('#save').attr('readonly', true);
				},
				success: function(data){
					mainCon.find('.basicInfoCon').show();
					mainCon.find('.basicInfoInput').hide();
					updateBasic(data.two);
					//更改性别图标
					if(data.two.sex == '男'){
						$('.basicInfo .basicInfoCon .bRight .bInfo li i.sex_m').attr('class','sex_f');
					}else{
						$('.basicInfo .basicInfoCon .bRight .bInfo li i.sex_f').attr('class','sex_m');
					}
					resumeJson = data.one;
				},
				error: function(data){
					var msgErr = '';
					var errors = $.parseJSON(data.responseText);
					$.each(errors, function(index, value){
						msgErr += value + ";<br>";
					});
					layer.msg(msgErr, {time: 2000});
				},
				complete: function(){
					$('#basicForm').find('#save').val('保存');
					$('#basicForm').find('#save').attr('disabled', false);
					$('#basicForm').find('#save').attr('readonly', false);
				}
			});
		}
	});
}
//基本信息表单赋值
function jsonBasic(){
	var basicForm = mainCon.find('#basicForm');
	basicForm.find('#resume_id').val(resumeJson.id);
	basicForm.find('#name').val(resumeJson.name);
	basicForm.find("input[name='sex'][value='" + resumeJson.sex + "']").attr("checked", true);

	selectWork_year.resetSelected(resumeJson.work_year);//设置选定值
	selectStatus.resetSelected(resumeJson.job_status);//设置选定值
	selectEdu.resetSelected(resumeJson.education);//设置选定值
	selectMarital.resetSelected(resumeJson.marital);//设置选定值

	basicForm.find('#longitude').val(resumeJson.longitude);
	basicForm.find('#latitude').val(resumeJson.latitude);
	basicForm.find('#place_name').val(resumeJson.place_name);
	if(resumeJson.place_name != ''){
		basicForm.find('#set_place').html(resumeJson.place_name);
	}
	//autoTime时间函数插件
	basicForm.find('#birthday').val(resumeJson.birthday);
	//地区联动
	basicForm.find('#homeaddress').val(resumeJson.homeaddress);
	basicForm.find("#address").val(resumeJson.address);
	//地区联动
	basicForm.find('#census').val(resumeJson.census);
	if(resumeJson.height != '0'){
		basicForm.find('#height').val(resumeJson.height);
	}
	if(resumeJson.chkPhotoOpen == '1'){
		basicForm.find("#chkPhotoOpen").attr("checked", true);
	}
	basicForm.find('#mobile').val(resumeJson.mobile);
	basicForm.find('#email').val(resumeJson.email);
	basicForm.find('#qq').val(resumeJson.qq);
	basicForm.find('#upavatar').find('img').attr('src', uploadavatar);
	if(resumeJson.chkphoto_open == '1'){
		basicForm.find("#chkphoto_open").attr("checked", true);
	}
}
//更新后的html赋值
function updateBasic(updateBasicJson){
	var basicInfoCon = mainCon.find('.basicInfoCon');
	basicInfoCon.find('.resumeTit h2').html(updateBasicJson.name);
	basicInfoCon.find('.bInfo .sexs').html(updateBasicJson.sex);
	basicInfoCon.find('.bInfo .birthday').html(updateBasicJson.birthday);
	basicInfoCon.find('.bInfo .work_year').html(updateBasicJson.work_year);
	basicInfoCon.find('.bInfo .homeaddress').html(updateBasicJson.homeaddress);
	basicInfoCon.find('.bInfo .job_status').html(updateBasicJson.job_status);
	basicInfoCon.find('.bInfo .education').html(updateBasicJson.education);
	basicInfoCon.find('.bInfo .marital').html(updateBasicJson.marital);
	basicInfoCon.find('.bInfo .census').html(updateBasicJson.census);
	basicInfoCon.find('.bInfo .height').html(updateBasicJson.height);
	basicInfoCon.find('.contact .mobile').html(updateBasicJson.mobile);
	basicInfoCon.find('.contact .phoneAddress').html(updateBasicJson.phoneAddress);
	basicInfoCon.find('.contact .email').html(updateBasicJson.email);
	basicInfoCon.find('#avatar img').attr('src', updateBasicJson.avatar);
}

// -求职意向-------------------------------------------------------------------------------------------------------------------------
function editObjective(othis){
	othis.parent('.resumeEdit').hide();
	mainCon.find('.objectiveCon').hide();
	mainCon.find('.objectiveInput').show();
	jsonObjective();

	//个人简历求职意向验证 使用jQuery Validate 插件进行验证
	$('#objectiveForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			intentionjobs: {
				required: true
			},
			jobarea1: {
				required: true
			},
			jobsort1: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			intentionjobs: {
				required: "请输入意向岗位"
			},
			jobarea1: {
				required: "请选择工作地区"
			},
			jobsort1: {
				required: "请选择工作岗位"
			}
		},

		submitHandler: function(form){
			var queryString = $('#objectiveForm').formSerialize();
			$.ajax({
				url: '/personal/resume_objective',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#objectiveForm').find('#save').val('请稍候');
					$('#objectiveForm').find('#save').attr('disabled', true);
					$('#objectiveForm').find('#save').attr('readonly', true);
				},
				success: function(data){
					mainCon.find('.objectiveCon').show();
					mainCon.find('.objectiveInput').hide();
					//跟新内容
					updateObjective(data.arr);
					objectiveJson = data.json;
				},
				error: function(data){
					var msgErr = '';
					var errors = $.parseJSON(data.responseText);
					$.each(errors, function(index, value){
						msgErr += value + ";<br>";
					});
					layer.msg(msgErr, {time: 2000});
				},
				complete: function(){
					$('#objectiveForm').find('#save').val('保存');
					$('#objectiveForm').find('#save').attr('disabled', false);
					$('#objectiveForm').find('#save').attr('readonly', false);
					othis.parent('.resumeEdit').show();
				}
			});
		}
	});


}
//求职意向表单赋值
function jsonObjective(){
	var objectiveForm = mainCon.find('#objectiveForm');
	objectiveForm.find('#resume_id').val(resumeJson.id);
	if(objectiveJson.isexpectedsalary == '1'){
		objectiveForm.find("#isexpectedsalary").attr("checked", true);
	}
	objectiveForm.find('#intentionjobs').val(objectiveJson.intentionjobs);    //地区
	objectiveForm.find('#workplace').val(objectiveJson.jobarea);
	objectiveForm.find('#jobarea1').val(objectiveJson.jobarea1);
	objectiveForm.find('#jobarea2').val(objectiveJson.jobarea2);
	objectiveForm.find('#jobarea3').val(objectiveJson.jobarea3);
	objectiveForm.find('#jobarea4').val(objectiveJson.jobarea4);
	objectiveForm.find('#jobarea5').val(objectiveJson.jobarea5);
	//职位
	objectiveForm.find('#jobsort').val(objectiveJson.jobsort);
	objectiveForm.find('#jobsort1').val(objectiveJson.jobsort1);
	objectiveForm.find('#jobsort2').val(objectiveJson.jobsort2);
	objectiveForm.find('#jobsort3').val(objectiveJson.jobsort3);
	objectiveForm.find('#jobsort4').val(objectiveJson.jobsort4);
	objectiveForm.find('#jobsort5').val(objectiveJson.jobsort5);

	selectExpectedsalary.resetSelected(objectiveJson.expectedsalary);//设置选定值
}
//求职意向更新表单
function updateObjective(updateObjectiveJson){
	var objectiveCon = mainCon.find('.objectiveCon');
	objectiveCon.find('.intentionjobs').html(mSubstr(updateObjectiveJson.intentionjobs, 42));
	objectiveCon.find('.jobsort').html(mSubstr(updateObjectiveJson.jobsort, 42));
	if(updateObjectiveJson.isexpectedsalary != '1'){
		objectiveCon.find('.expectedsalary').html(updateObjectiveJson.expectedsalary);
	}else{
		objectiveCon.find('.expectedsalary').html('面议');
	}
	objectiveCon.find('.jobarea').html(mSubstr(updateObjectiveJson.jobarea, 42));
}

// -自我评价-------------------------------------------------------------------------------------------------------------------------
//编辑自我评价
function editEvaluation(othis){
	othis.parent('.resumeEdit').hide();
	mainCon.find('.selfEvaluationCon').hide();
	mainCon.find('.selfEvaluationInput').show();
	jsonEvaluation();
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$('#evaluationForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {},
		//错误信息提示修改
		messages: {},
		submitHandler: function(form){
			var queryString = $('#evaluationForm').formSerialize();
			$.ajax({
				url: '/personal/resume_evaluation',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#evaluationForm').find('#save').val('请稍候');
					$('#evaluationForm').find('#save').attr('disabled', true);
					$('#evaluationForm').find('#save').attr('readonly', true);
				},
				success: function(data){
					mainCon.find('.selfEvaluationCon').show();
					mainCon.find('.selfEvaluationInput').hide();
					//跟新内容
					updateEvaluation(data.json);
					evaluationJson = data.json;
				},
				error: function(data){
					layer.msg('网络原因引起的错误', {time: 2000});
				},
				complete: function(){
					$('#evaluationForm').find('#save').val('保存');
					$('#evaluationForm').find('#save').removeAttr('disabled');
					$('#evaluationForm').find('#save').removeAttr('readonly');
					othis.parent('.resumeEdit').show();
				}
			});
		}
	});
}
//自我评价赋值
function jsonEvaluation(){
	var evaluationForm = mainCon.find('#evaluationForm');
	evaluationForm.find('#resume_id').val(resumeJson.id);
	evaluationForm.find('#introduction').val(evaluationJson.introduction);
}
//自我评价更新表单
function updateEvaluation(updateEvaluationJson){
	var evaluationCon = mainCon.find('.selfEvaluationCon');
	evaluationCon.find('.con').html(nl2br(updateEvaluationJson.introduction));

	//计算完成度
	if(updateEvaluationJson.introduction == '' || updateEvaluationJson.introduction == 'undefined'){
		completion(2, 0);
	}else{
		completion(2, 1);
	}
}

// -工作经历-------------------------------------------------------------------------------------------------------------------------
//添加工作经历
function addWorkExp(othis, otype){
	othis.parents('.worker').find('.resumeAdd').hide();
	var workerCon = mainCon.find('.worker').find('.workerCon');
	workerCon.find('.workerInput').remove();
	workerCon.find('.workerExp').remove();
	workerCon.find('.listCon').show();
	workerCon.prepend(wInput);
	workerCon.find('.workerInput').css({'margin-top': '0'}).show();
	if(otype == 'add') workerCon.find('.workerInput .sAdd').show();

	//重新设置参数
	selectComkind = mainCon.find('.worker').find("#comkind").select({optionData: option_comkind, selected: 5});
	selectScale = mainCon.find('.worker').find("#scale").select({optionData: option_employee_num, defaults: null});
	selectIndustry = mainCon.find('.worker').find("#industry").select({optionData: option_industry, defaults: null});
	//工作经历入职时间
	mainCon.find('.worker').find("#showStart").autoTime({
		year: "startYear",                               //弹出层年份
		month: "startMonth",                             //弹出层月份
		established: '#starttime'                       //入职时间
	});
	mainCon.find('.worker').find("#showEnd").autoTime({
		year: "endYear",                               //弹出层年份
		month: "endMonth",                             //弹出层月份
		established: '#endtime',                       //入职时间
		toDate: true                                    //是不是显示至今
	});
	//检查表单内容
	checkWorkInp(othis, 'add');
}
//检查表单内容
function checkWorkInp(othis, otype){
	//入职时间验证
	$.validator.addMethod("checkTime", function(value, element, param){
		var endtime = mainCon.find('.worker').find("#" + param[0]).val();
		if(value == '' && endtime == ''){
			return false;
		}else if(value != ''){
			if(endtime > value || endtime == '0000-00-00'){
				return true;
			}else{
				return false;
			}
		}else if(value == ''){
			return false;
		}
		else{
			return true;
		}
	}, "请选择正确的开始年份和结束年份");
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$('#workForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			company: {
				required: true
			},
			comkind: {
				required: true
			},
			scale: {
				required: true
			},
			industry: {
				required: true
			},
			starttime: {
				checkTime: ['endtime']
			},
			post: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			company: {
				required: "请输入公司名称"
			},
			comkind: {
				required: "请选择公司性质"
			},
			scale: {
				required: "请选择企业规模"
			},
			industry: {
				required: "请选择所属行业"
			},
			post: {
				required: "请输入职位名称"
			}
		},
		submitHandler: function(form){
			var queryString = $('#workForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_work_exp',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#workForm').find('#saveWork').val('请稍候');
						$('#workForm').find('#saveWork').attr('disabled', true);
						$('#workForm').find('#saveWork').attr('readonly', true);
					},
					success: function(data){
						//判断添加类型
						workCancel(othis);
						//跟新内容
						updateWorkExp(data.arr);
						appendWorkJson = data.json;
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#workForm').find('#saveWork').val('保存');
						$('#workForm').find('#saveWork').removeAttr('disabled');
						$('#workForm').find('#saveWork').removeAttr('readonly');
					}
				});
			}else{
				if(mainCon.find('.worker').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_work_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#workForm').find('#saveWork').val('请稍候');
							$('#workForm').find('#saveWork').attr('disabled', true);
							$('#workForm').find('#saveWork').attr('readonly', true);
						},
						success: function(data){
							//跟新内容
							appendWorkerExp(data.arr);
							appendWorkJson = data.json;
							//判断添加类型
							workCancel(othis);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#workForm').find('#saveWork').val('保存');
							$('#workForm').find('#saveWork').removeAttr('disabled');
							$('#workForm').find('#saveWork').removeAttr('readonly');
						}
					});
				}else if(mainCon.find('.worker').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_work_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#workForm').find('#addSaveWork').val('请稍候');
							$('#workForm').find('#addSaveWork').attr('disabled', true);
							$('#workForm').find('#addSaveWork').attr('readonly', true);
						},
						success: function(data){

							document.getElementById("workForm").reset();
							selectComkind = $("#comkind").select({optionData: option_comkind, selected: 5});
							selectScale = $("#scale").select({optionData: option_employee_num, selected: ''});
							selectIndustry = $("#industry").select({optionData: option_industry, selected: ''});

							othis.parents('.worker').find('#starttime').val('');
							othis.parents('.worker').find('#endtime').val('');
							othis.parents('.worker').find('.selTime').css({"background": "#fff"});
							othis.parents('.worker').find('.selTime input').css({"background": "#fff"});

							//跟新内容
							appendWorkerExp(data.arr);
							appendWorkJson = data.json;
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#workForm').find('#addSaveWork').val('保存并添加');
							$('#workForm').find('#addSaveWork').removeAttr('disabled');
							$('#workForm').find('#addSaveWork').removeAttr('readonly');
						}
					});
				}
			}

		}
	});
}
//更新工作经历
function updateWorkExp(updateWorkExp){
	var WorkExpCon = mainCon.find('.workerCon').find("#listCon" + updateWorkExp.id);
	WorkExpCon.find('.starttime').html(updateWorkExp.starttime);
	WorkExpCon.find('.endtime').html(updateWorkExp.endtime);
	WorkExpCon.find('.post').html(mSubstr(updateWorkExp.post, 26));
	WorkExpCon.find('.company').html(mSubstr(updateWorkExp.company, 34));
	WorkExpCon.find('.comkind').html(updateWorkExp.comkind);
	WorkExpCon.find('.scale').html(updateWorkExp.scale);
	WorkExpCon.find('.industry').html(updateWorkExp.industry);
	WorkExpCon.find('.con').html(nl2br(updateWorkExp.content));

}
//追加工作经历
function appendWorkerExp(workExp){
	//添加完成度
	if(mainCon.find('.worker').find('.workerCon').find('.listCon').length <= 0){
		completion(3, 1);
	}
	var str = '';
	str += '<div class="listCon" id="listCon' + workExp.id + '">';
	str += '<div class="listLeft"><span class="listTime"><span class="starttime">' + workExp.starttime + '</span>~<span class="endtime">' + workExp.endtime + '</span></span></div>';
	str += '<div class="listCenter">';
	str += '<div class="tit">';
	str += '<strong class="post">' + mSubstr(workExp.post, 26) + '</strong>';
	str += '<b>|</b>';
	str += '<span class="company">' + mSubstr(workExp.company, 34) + '</span>';
	str += '</div>';
	str += '<div class="info">';
	str += '<ul>';
	str += '<li class="comkind">' + workExp.comkind + '</li>';
	str += '<b>-</b>';
	str += '<li class="scale">' + workExp.scale + '</li>';
	str += '<b>-</b>';
	str += '<li class="industry">' + workExp.industry + '</li>';
	str += '</ul>';
	str += '<div class="con">' + nl2br(workExp.content) + '</div>';
	str += '</div>';
	str += '</div>';
	str += '<div class="listRight">';
	str += '<span class="edit"><input onclick="editWorker($(this),\'' + workExp.id + '\')" value="编辑" type="button"></span>';
	str += '<span class="del"><input  onclick="delWorker(\'' + workExp.id + '\')"  value="删除" type="button"></span>';
	str += '</div>';
	str += '</div>';
	mainCon.find('.worker').find('.workerCon').find('.workerInput').after(str);
}
//编辑工作经历
function editWorker(othis, id){
	$.ajax({
		url: '/personal/edit_work_exp',
		dataType: "json",
		data: "id=" + id + "&_token=" + _token,
		type: "POST",
		success: function(data){
			othis.parents('.worker').find('.resumeAdd').show();
			mainCon.find('.worker').find('.workerCon').find('.workerInput').remove();
			othis.parents('#listCon' + id).after(wInput);
			mainCon.find('.worker').find('.workerCon').find('.workerInput').show();

			selectComkind = mainCon.find('.worker').find("#comkind").select({optionData: option_comkind, selected: 5});
			selectScale = mainCon.find('.worker').find("#scale").select({optionData: option_employee_num});
			selectIndustry = mainCon.find('.worker').find("#industry").select({optionData: option_industry});

			var workForm = mainCon.find('#workForm');
			workForm.find('#id').val(data.id);
			workForm.find('#company').val(data.company);
			workForm.find("#comkind").select({optionData: option_comkind, selected: data.comkind});
			workForm.find("#scale").select({optionData: option_employee_num, selected: data.scale});
			workForm.find("#industry").select({optionData: option_industry, selected: data.industry});

			workForm.find("#starttime").val(data.starttime);
			if(data.endtime == '0000-00-00'){
				workForm.find("#endtime").val(data.endtime);
			}else{
				workForm.find("#endtime").val(data.endtime);
			}
			workForm.find("#post").val(data.post);
			workForm.find("#content").val(data.content);

			//工作经历入职时间
			mainCon.find('.worker').find("#showStart").autoTime({
				year: "startYear",                               //弹出层年份
				month: "startMonth",                             //弹出层月份
				established: '#starttime'                       //入职时间
			});
			mainCon.find('.worker').find("#showEnd").autoTime({
				year: "endYear",                               //弹出层年份
				month: "endMonth",                             //弹出层月份
				established: '#endtime',                       //入职时间
				toDate: true                                    //是不是显示至今
			});

			mainCon.find('.worker').find('.workerCon').find('.listCon').each(function(){
				$(this).parents('.workerCon').find('#listCon' + id).hide().siblings().show();
			});
			//检查表单内容
			checkWorkInp(othis, 'mod');
		},
		error: function(data){
			layer.msg('可能网络原因引起的错误');
		},
		complete: function(){

		}
	});
}
//删除工作经历
function delWorker(id){
	layer.confirm('您确定要删除这个工作经历吗？', {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.post("/personal/del_work_exp", {
			'id': id,
			'_token': _token
		}, function(data){
			if(data.status == 0){
				layer.msg(data.msg, {icon: 6, time: 1000});
				mainCon.find('.worker').find('.workerCon').find('#listCon' + id).remove();
				//添加完成度
				if(mainCon.find('.worker').find('.workerCon').find('.listCon').length <= 0){
					completion(3, 0);
				}
			}else{
				layer.msg(data.msg, {icon: 5, time: 1500});
			}
		});
	}, function(){

	});
}
//取消工作经历
function workCancel(othis){
	othis.parents('.worker').find('.resumeAdd').show();
	mainCon.find('.worker').find('.workerInput').remove();
	mainCon.find('.worker').find('.workerCon').find('.listCon').show();
}
//判断添加工作经历类型
function workType(type){
	mainCon.find('.worker').find("#otype").val(type);
}

// -教育经历-------------------------------------------------------------------------------------------------------------------------
//添加教育经历
function addEduExp(othis, otype){
	othis.parents('.education').find('.resumeAdd').hide();
	var educationCon = mainCon.find('.education').find('.educationCon');

	educationCon.find('.eduInput').remove();
	educationCon.find('.eduExp').remove();
	educationCon.find('.listCon').show();
	educationCon.prepend(eduInput);
	educationCon.find('.eduInput').css({'margin-top': '0'}).show();
	if(otype == 'add') educationCon.find('.eduInput .sAdd').show();
	//重新设置参数
	selectEducation = educationCon.find("#education").select({optionData: option_education, defaults: null});

	//教育经历入职时间
	mainCon.find('.education').find('#eInput').find("#eduStart").autoTime({
		year: "startYear",                               //弹出层年份
		month: "startMonth",                             //弹出层月份
		established: '#starttime'                       //入职时间
	});
	mainCon.find('.education').find('#eInput').find("#eduEnd").autoTime({
		year: "endYear",                               //弹出层年份
		month: "endMonth",                             //弹出层月份
		established: '#endtime',                       //入职时间
		toDate: true                                    //是不是显示至今
	});

	//教育经历入职时间
	mainCon.find('.education').find('#tInput').find("#eduStart").autoTime({
		year: "startYear",                               //弹出层年份
		month: "startMonth",                             //弹出层月份
		established: '#starttime'                       //入职时间
	});
	mainCon.find('.education').find('#tInput').find("#eduEnd").autoTime({
		year: "endYear",                               //弹出层年份
		month: "endMonth",                             //弹出层月份
		established: '#endtime',                       //入职时间
		toDate: true                                    //是不是显示至今
	});
	//选择教育培训经历类型
	educationCon.find('input[name="edu_type"]').click(function(){
		if($(this).val() == '1'){
			educationCon.find('#eInput').show();
			educationCon.find('#tInput').hide();
		}else if($(this).val() == '2'){
			educationCon.find('#eInput').hide();
			educationCon.find('#tInput').show();
		}
	});
	//检查表单内容
	checkEduInp(othis, 'add');
	checkTrainInp(othis, 'add');
}
//检查教育经历表单内容
function checkEduInp(othis, otype){
	//入职时间验证
	$.validator.addMethod("checkTime", function(value, element, param){
		var endtime = mainCon.find('.education').find('#eInput').find("#" + param[0]).val();
		if(value == '' && endtime == ''){
			return false;
		}else if(value != ''){
			if(endtime > value || endtime == '0000-00-00'){
				return true;
			}else{
				return false;
			}
		}else if(value == ''){
			return false;
		}
		else{
			return true;
		}
	}, "请选择正确的开始年份和结束年份");
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$('#eduForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			school: {
				required: true
			},
			starttime: {
				checkTime: ['endtime']
			},
			education: {
				required: true
			},
			speciality: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			school: {
				required: "请输入学校名称"
			},
			education: {
				required: "请选择学历"
			},
			speciality: {
				required: "请输入专业名称"
			}
		},
		submitHandler: function(form){
			var queryString = $('#eduForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_edu_exp',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#eduForm').find('#saveEdu').val('请稍候');
						$('#eduForm').find('#saveEdu').attr('disabled', true);
						$('#eduForm').find('#saveEdu').attr('readonly', true);
					},
					success: function(data){
						//判断添加类型
						eduCancel(othis);
						//更新内容
						updateEduExp(data.arr);
						appendEduJson = data.json;
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#eduForm').find('#saveEdu').val('保存');
						$('#eduForm').find('#saveEdu').removeAttr('disabled');
						$('#eduForm').find('#saveEdu').removeAttr('readonly');
					}
				});
			}else{
				if(mainCon.find('.education').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_edu_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#eduForm').find('#saveEdu').val('请稍候');
							$('#eduForm').find('#saveEdu').attr('disabled', true);
							$('#eduForm').find('#saveEdu').attr('readonly', true);
						},
						success: function(data){
							//跟新内容
							appendEduExp(data.arr);
							appendEduJson = data.json;
							//判断添加类型
							eduCancel(othis);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#eduForm').find('#saveEdu').val('保存');
							$('#eduForm').find('#saveEdu').removeAttr('disabled');
							$('#eduForm').find('#saveEdu').removeAttr('readonly');
						}
					});
				}else if(mainCon.find('.education').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_edu_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#eduForm').find('#addSaveEdu').val('请稍候');
							$('#eduForm').find('#addSaveEdu').attr('disabled', true);
							$('#eduForm').find('#addSaveEdu').attr('readonly', true);
						},
						success: function(data){
							document.getElementById("eduForm").reset();
							selectEducation = mainCon.find('.education').find("#education").select({
								optionData: option_education,
								selected: ''
							});

							othis.parents('.education').find('#starttime').val('');
							othis.parents('.education').find('#endtime').val('');
							othis.parents('.education').find('.selTime').css({"background": "#fff"});
							othis.parents('.education').find('.selTime input').css({"background": "#fff"});

							//更新内容
							appendEduExp(data.arr);
							appendEduJson = data.json;
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#eduForm').find('#addSaveEdu').val('保存并添加');
							$('#eduForm').find('#addSaveEdu').removeAttr('disabled');
							$('#eduForm').find('#addSaveEdu').removeAttr('readonly');
						}
					});
				}
			}

		}
	});
}
//检查培训机构表单内容
function checkTrainInp(othis, otype){
	//入职时间验证
	$.validator.addMethod("checkTime2", function(value, element, param){
		var endtime = mainCon.find('.education').find('#tInput').find("#" + param[0]).val();
		if(value == '' && endtime == ''){
			return false;
		}else if(value != ''){
			if(endtime > value || endtime == '0000-00-00'){
				return true;
			}else{
				return false;
			}
		}else if(value == ''){
			return false;
		}
		else{
			return true;
		}
	}, "请选择正确的开始年份和结束年份");
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$('#trainForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			school: {
				required: true
			},
			starttime: {
				checkTime2: ['endtime']
			},
			speciality: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			school: {
				required: "请输入培训机构"
			},
			speciality: {
				required: "请输入培训项目"
			}
		},
		submitHandler: function(form){
			var queryString = $('#trainForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_edu_exp',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#trainForm').find('#saveEdu').val('请稍候');
						$('#trainForm').find('#saveEdu').attr('disabled', true);
						$('#trainForm').find('#saveEdu').attr('readonly', true);
					},
					success: function(data){
						//判断添加类型
						eduCancel(othis);
						//更新内容
						updateTrainExp(data.arr);
						appendEduJson = data.json;
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#trainForm').find('#saveEdu').val('保存');
						$('#trainForm').find('#saveEdu').removeAttr('disabled');
						$('#trainForm').find('#saveEdu').removeAttr('readonly');
					}
				});
			}else{
				if(mainCon.find('.education').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_edu_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#trainForm').find('#saveEdu').val('请稍候');
							$('#trainForm').find('#saveEdu').attr('disabled', true);
							$('#trainForm').find('#saveEdu').attr('readonly', true);
						},
						success: function(data){
							//跟新内容
							appendTrainExp(data.arr);
							appendEduJson = data.json;
							//判断添加类型
							eduCancel(othis);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#trainForm').find('#saveEdu').val('保存');
							$('#trainForm').find('#saveEdu').removeAttr('disabled');
							$('#trainForm').find('#saveEdu').removeAttr('readonly');
						}
					});
				}else if(mainCon.find('.education').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_edu_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#trainForm').find('#addSaveEdu').val('请稍候');
							$('#trainForm').find('#addSaveEdu').attr('disabled', true);
							$('#trainForm').find('#addSaveEdu').attr('readonly', true);
						},
						success: function(data){
							document.getElementById("trainForm").reset();

							othis.parents('.education').find('#starttime').val('');
							othis.parents('.education').find('#endtime').val('');
							othis.parents('.education').find('.selTime').css({"background": "#fff"});
							othis.parents('.education').find('.selTime input').css({"background": "#fff"});

							//更新内容
							appendTrainExp(data.arr);
							appendEduJson = data.json;
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#trainForm').find('#addSaveEdu').val('保存并添加');
							$('#trainForm').find('#addSaveEdu').removeAttr('disabled');
							$('#trainForm').find('#addSaveEdu').removeAttr('readonly');
						}
					});
				}
			}

		}
	});
}
//追加教育经历
function appendEduExp(eduExp){
	//添加完成度
	if(mainCon.find('.education').find('.educationCon').find('.listCon').length <= 0){
		completion(4, 1);
	}
	var str = '';
	str += '<div class="listCon" id="listCon' + eduExp.id + '">';
	str += '<div class="listLeft"><span class="listTime"><span class="starttime">' + eduExp.starttime + '</span>~<span class="endtime">' + eduExp.endtime + '</span></span></div>';
	str += '<div class="listCenter">';
	str += '<div class="tit">';
	str += '<strong class="education">' + eduExp.education + '</strong>';
	str += '<b>|</b>';
	str += '<span class="school">' + mSubstr(eduExp.school, 44) + '</span>';
	str += '</div>';
	str += '<div class="info">';
	str += '<span class="speciality">' + eduExp.speciality + '</span>';
	str += '<div class="con">' + nl2br(eduExp.description) + '</div>';
	str += '</div>';
	str += '</div>';
	str += '<div class="listRight">';
	str += '<span class="edit"><input onclick="editEdu($(this),\'' + eduExp.id + '\')" value="编辑" type="button"></span>';
	str += '<span class="del"><input  onclick="delEdu(\'' + eduExp.id + '\')"  value="删除" type="button"></span>';
	str += '</div>';
	str += '</div>';
	mainCon.find('.education').find('.educationCon').find('.eduInput').after(str);
}
//追加培训机构经历
function appendTrainExp(eduExp){
	//添加完成度
	if(mainCon.find('.education').find('.educationCon').find('.listCon').length <= 0){
		completion(4, 1);
	}
	var str = '';
	str += '<div class="listCon" id="listCon' + eduExp.id + '">';
	str += '<div class="listLeft"><span class="listTime"><span class="starttime">' + eduExp.starttime + '</span>~<span class="endtime">' + eduExp.endtime + '</span></span></div>';
	str += '<div class="listCenter">';
	str += '<div class="tit">';
	str += '<strong class="education">' + mSubstr(eduExp.speciality, 50) + '</strong>';
	str += '<b>|</b>';
	str += '<span class="school">' + mSubstr(eduExp.school, 44) + '</span>';
	str += '</div>';
	str += '<div class="info">';
	str += '<div class="con">' + nl2br(eduExp.description) + '</div>';
	str += '</div>';
	str += '</div>';
	str += '<div class="listRight">';
	str += '<span class="edit"><input onclick="editEdu($(this),\'' + eduExp.id + '\')" value="编辑" type="button"></span>';
	str += '<span class="del"><input  onclick="delEdu(\'' + eduExp.id + '\')"  value="删除" type="button"></span>';
	str += '</div>';
	str += '</div>';
	mainCon.find('.education').find('.educationCon').find('.eduInput').after(str);
}
//编辑教育经历
function editEdu(othis, id){
	$.ajax({
		url: '/personal/edit_edu_exp',
		dataType: "json",
		data: "id=" + id + "&_token=" + _token,
		type: "POST",
		success: function(data){
			othis.parents('.education').find('.resumeAdd').show();
			mainCon.find('.education').find('.educationCon').find('.eduInput').remove();
			othis.parents('#listCon' + id).after(eduInput);
			mainCon.find('.education').find('.educationCon').find('.eduInput').show();
			mainCon.find('.education').find('.educationCon').find('.eduInput').find("#sel_type").remove();

			//判断教育类型
			if(data.edu_type == '1'){
				mainCon.find('.education').find('#eInput').show();
				mainCon.find('.education').find('#tInput').hide();
				var eduForm = mainCon.find('.education').find('#eInput').find('#eduForm');
				selectEducation = mainCon.find('.education').find("#education").select({
					optionData: option_education,
					selected: ''
				});
				eduForm.find("#education").select({optionData: option_education, selected: data.education});
				if(data.type == '1'){
					eduForm.find("#type").attr("checked", true);
				}
			}else if(data.edu_type == '2'){
				mainCon.find('.education').find('#eInput').hide();
				mainCon.find('.education').find('#tInput').show();
				var eduForm = mainCon.find('.education').find('#tInput').find('#trainForm');
			}

			eduForm.find('#id').val(data.id);
			eduForm.find('#school').val(data.school);

			eduForm.find("#starttime").val(data.starttime);
			if(data.endtime == '0000-00-00'){
				eduForm.find("#endtime").val(data.endtime);
			}else{
				eduForm.find("#endtime").val(data.endtime);
			}
			eduForm.find("#speciality").val(data.speciality);
			eduForm.find("#description").val(data.description);
			//教育经历入职时间
			eduForm.find("#eduStart").autoTime({
				year: "startYear",                               //弹出层年份
				month: "startMonth",                             //弹出层月份
				established: '#starttime'                       //入职时间
			});
			eduForm.find("#eduEnd").autoTime({
				year: "endYear",                               //弹出层年份
				month: "endMonth",                             //弹出层月份
				established: '#endtime',                       //入职时间
				toDate: true                                    //是不是显示至今
			});


			mainCon.find('.education').find('.educationCon').find('.listCon').each(function(){
				$(this).parents('.educationCon').find('#listCon' + id).hide().siblings().show();
			});
			//检查表单内容
			checkEduInp(othis, 'mod');
			checkTrainInp(othis, 'mod');
		},
		error: function(data){
			layer.msg('可能网络原因引起的错误');
		},
		complete: function(){

		}
	});
}
//更新教育经历
function updateEduExp(updateEduExp){
	var EduExpCon = mainCon.find('.educationCon').find("#listCon" + updateEduExp.id);
	EduExpCon.find('.starttime').html(updateEduExp.starttime);
	EduExpCon.find('.endtime').html(updateEduExp.endtime);
	EduExpCon.find('.education').html(updateEduExp.education);
	EduExpCon.find('.speciality').html(mSubstr(updateEduExp.speciality, 44));
	EduExpCon.find('.school').html(mSubstr(updateEduExp.school, 50));
	EduExpCon.find('.con').html(nl2br(updateEduExp.description));

}
//更新培训机构经历
function updateTrainExp(updateTrainExp){
	var EduExpCon = mainCon.find('.educationCon').find("#listCon" + updateTrainExp.id);
	EduExpCon.find('.starttime').html(updateTrainExp.starttime);
	EduExpCon.find('.endtime').html(updateTrainExp.endtime);
	EduExpCon.find('.education').html(mSubstr(updateTrainExp.speciality, 44));
	EduExpCon.find('.school').html(mSubstr(updateTrainExp.school, 50));
	EduExpCon.find('.con').html(nl2br(updateTrainExp.description));
}
//取消教育经历
function eduCancel(othis){
	othis.parents('.education').find('.resumeAdd').show();
	mainCon.find('.education').find('.eduInput').remove();
	mainCon.find('.education').find('.educationCon').find('.listCon').show();
}
//删除教育经历
function delEdu(id){
	layer.confirm('您确定要删除这个教育经历吗？', {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.post("/personal/del_edu_exp", {
			'id': id,
			'_token': _token
		}, function(data){
			if(data.status == 0){
				layer.msg(data.msg, {icon: 6, time: 1000});
				mainCon.find('.education').find('.educationCon').find('#listCon' + id).remove();
				//添加完成度
				if(mainCon.find('.education').find('.educationCon').find('.listCon').length <= 0){
					completion(4, 0);
				}
			}else{
				layer.msg(data.msg, {icon: 5, time: 1500});
			}
		});
	}, function(){

	});
}
//判断类型
function eduType(type){
	mainCon.find('.education').find("#otype").val(type);
}

// -项目经验-------------------------------------------------------------------------------------------------------------------------
//添加项目经验
function addProjectExp(othis, otype){

	othis.parents('.project').find('.resumeAdd').hide();
	var projectCon = mainCon.find('.project').find('.projectCon');

	projectCon.find('.projectInput').remove();
	projectCon.find('.projectExp').remove();
	projectCon.find('.listCon').show();
	projectCon.prepend(projectInput);
	projectCon.find('.projectInput').css({'margin-top': '0'}).show();
	if(otype == 'add') projectCon.find('.projectInput .sAdd').show();

	//项目经验入职时间
	mainCon.find('.project').find("#projectStart").autoTime({
		year: "startYear",                               //弹出层年份
		month: "startMonth",                             //弹出层月份
		established: '#starttime'                       //入职时间
	});
	mainCon.find('.project').find("#projectEnd").autoTime({
		year: "endYear",                               //弹出层年份
		month: "endMonth",                             //弹出层月份
		established: '#endtime',                       //入职时间
		toDate: true                                    //是不是显示至今
	});
	//检查表单内容
	checkProjectInp(othis, 'add');
}
//检查表单内容
function checkProjectInp(othis, otype){
	//入职时间验证
	$.validator.addMethod("checkTime", function(value, element, param){
		var endtime = mainCon.find('.project').find("#" + param[0]).val();
		if(value == '' && endtime == ''){
			return false;
		}else if(value != ''){
			if(endtime > value || endtime == '0000-00-00'){
				return true;
			}else{
				return false;
			}
		}else if(value == ''){
			return false;
		}
		else{
			return true;
		}
	}, "请选择正确的开始年份和结束年份");
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$('#projectForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			project_name: {
				required: true
			},
			starttime: {
				checkTime: ['endtime']
			},
			post: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			project_name: {
				required: "请输入项目名称"
			},
			project: {
				required: "请选择学历"
			},
			post: {
				required: "请输入担任职务"
			}
		},
		submitHandler: function(form){
			var queryString = $('#projectForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_project_exp',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#projectForm').find('#saveProject').val('请稍候');
						$('#projectForm').find('#saveProject').attr('disabled', true);
						$('#projectForm').find('#saveProject').attr('readonly', true);
					},
					success: function(data){
						//判断添加类型
						projectCancel(othis);
						//跟新内容
						updateProjectExp(data.arr);
						appendProjectJson = data.json;
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#projectForm').find('#saveProject').val('保存');
						$('#projectForm').find('#saveProject').removeAttr('disabled');
						$('#projectForm').find('#saveProject').removeAttr('readonly');
					}
				});
			}else{
				if(mainCon.find('.project').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_project_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#projectForm').find('#saveProject').val('请稍候');
							$('#projectForm').find('#saveProject').attr('disabled', true);
							$('#projectForm').find('#saveProject').attr('readonly', true);
						},
						success: function(data){
							//跟新内容
							appendProjectExp(data.arr);
							appendProjectJson = data.json;
							//判断添加类型
							projectCancel(othis);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#projectForm').find('#saveProject').val('保存');
							$('#projectForm').find('#saveProject').removeAttr('disabled');
							$('#projectForm').find('#saveProject').removeAttr('readonly');
						}
					});
				}else if(mainCon.find('.project').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_project_exp',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#projectForm').find('#addSaveProject').val('请稍候');
							$('#projectForm').find('#addSaveProject').attr('disabled', true);
							$('#projectForm').find('#addSaveProject').attr('readonly', true);
						},
						success: function(data){
							document.getElementById("projectForm").reset();

							othis.parents('.project').find('#starttime').val('');
							othis.parents('.project').find('#endtime').val('');
							othis.parents('.project').find('.selTime').css({"background": "#fff"});
							othis.parents('.project').find('.selTime input').css({"background": "#fff"});

							//更新内容
							appendProjectExp(data.arr);
							appendProjectJson = data.json;
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#projectForm').find('#addSaveProject').val('保存并添加');
							$('#projectForm').find('#addSaveProject').removeAttr('disabled');
							$('#projectForm').find('#addSaveProject').removeAttr('readonly');
						}
					});
				}
			}

		}
	});
}
//追加项目经验
function appendProjectExp(projectExp){
	//添加完成度
	if(mainCon.find('.project').find('.projectCon').find('.listCon').length <= 0){
		completion(5, 1);
	}
	var str = '';
	str += '<div class="listCon" id="listCon' + projectExp.id + '">';
	str += '<div class="listLeft"><span class="listTime"><span class="starttime">' + projectExp.starttime + '</span>~<span class="endtime">' + projectExp.endtime + '</span></span></div>';
	str += '<div class="listCenter">';
	str += '<div class="tit">';
	str += '<strong class="project_name">' + mSubstr(projectExp.project_name, 26) + '</strong>';
	str += '<b>|</b>';
	str += '<span>担任职位：</span><span class="post">' + mSubstr(projectExp.post, 26) + '</span>';
	str += '</div>';
	str += '<div class="info">';
	str += '<span class="con">' + nl2br(projectExp.content) + '</span>';
	str += '</div>';
	str += '</div>';
	str += '<div class="listRight">';
	str += '<span class="edit"><input onclick="editProject($(this),\'' + projectExp.id + '\')" value="编辑" type="button"></span>';
	str += '<span class="del"><input  onclick="delProject(\'' + projectExp.id + '\')"  value="删除" type="button"></span>';
	str += '</div>';
	str += '</div>';
	mainCon.find('.project').find('.projectCon').find('.projectInput').after(str);
}
//编辑项目经验
function editProject(othis, id){
	//表单赋值
	$.ajax({
		url: '/personal/edit_project_exp',
		dataType: "json",
		data: "id=" + id + "&_token=" + _token,
		type: "POST",
		success: function(data){
			othis.parents('.project').find('.resumeAdd').show();
			mainCon.find('.project').find('.projectCon').find('.projectInput').remove();
			othis.parents('#listCon' + id).after(projectInput);
			mainCon.find('.project').find('.projectCon').find('.projectInput').show();

			var projectForm = mainCon.find('.project').find('#projectForm');
			projectForm.find('#id').val(data.id);
			projectForm.find('#project_name').val(data.project_name);
			projectForm.find("#starttime").val(data.starttime);

			if(data.endtime == '0000-00-00'){
				projectForm.find("#endtime").val(data.endtime);
			}else{
				projectForm.find("#endtime").val(data.endtime);
			}
			projectForm.find("#post").val(data.post);
			projectForm.find("#content").html(data.content);

			//项目经验入职时间
			mainCon.find('.project').find("#projectStart").autoTime({
				year: "startYear",                               //弹出层年份
				month: "startMonth",                             //弹出层月份
				established: '#starttime'                       //入职时间
			});
			mainCon.find('.project').find("#projectEnd").autoTime({
				year: "endYear",                               //弹出层年份
				month: "endMonth",                             //弹出层月份
				established: '#endtime',                       //入职时间
				toDate: true                                    //是不是显示至今
			});

			mainCon.find('.project').find('.projectCon').find('.listCon').each(function(){
				$(this).parents('.projectCon').find('#listCon' + id).hide().siblings().show();
			});
			//检查表单内容
			checkProjectInp(othis, 'mod');
		},
		error: function(data){
			layer.msg('可能网络原因引起的错误');
		},
		complete: function(){

		}
	});
}
//更新项目经验
function updateProjectExp(updateProjectExp){
	var ProjectExpCon = mainCon.find('.projectCon').find("#listCon" + updateProjectExp.id);
	ProjectExpCon.find('.starttime').html(updateProjectExp.starttime);
	ProjectExpCon.find('.endtime').html(updateProjectExp.endtime);
	ProjectExpCon.find('.project_name').html(mSubstr(updateProjectExp.project_name, 26));
	ProjectExpCon.find('.post').html(mSubstr(updateProjectExp.post, 20));
	ProjectExpCon.find('.con').html(nl2br(updateProjectExp.content));
}
//取消项目经验
function projectCancel(othis){
	othis.parents('.project').find('.resumeAdd').show();
	mainCon.find('.project').find('.projectInput').remove();
	mainCon.find('.project').find('.projectCon').find('.listCon').show();
}
//删除项目经验
function delProject(id){
	layer.confirm('您确定要删除这个项目经验吗？', {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.post("/personal/del_project_exp", {
			'id': id,
			'_token': _token
		}, function(data){
			if(data.status == 0){
				layer.msg(data.msg, {icon: 6, time: 1000});
				mainCon.find('.project').find('.projectCon').find('#listCon' + id).remove();
				//添加完成度
				if(mainCon.find('.project').find('.projectCon').find('.listCon').length <= 0){
					completion(5, 0);
				}
			}else{
				layer.msg(data.msg, {icon: 5, time: 1500});
			}
		});
	}, function(){

	});
}
//判断类型
function projectType(type){
	mainCon.find('.project').find("#otype").val(type);
}

// -语言能力-------------------------------------------------------------------------------------------------------------------------
//赋值语言能力
function jsonLanguage(){
	var languageForm = mainCon.find('#languageForm');
	languageForm.find('#resume_id').val(resumeJson.id);
	//console.log(languageJson)
	if(languageJson.length > 0){
		$.each(languageJson, function(k, v){
			var str = '';
			str += '<dl id="languageName' + v.id + '">';
			str += '<div class="sList"></div>';
			str += '<input name="id[]" type="hidden" id="id" value="' + v.id + '">';
			str += '<dd>';
			str += '<input id="language" name="language[]" type="hidden">';
			str += '<div id="language_select" class="select" style="width:160px;">';
			str += '<span><a></a></span><i></i></div>';
			str += '</dd>';

			str += '<dd>';
			str += '<input id="degree" name="degree[]" type="hidden">';
			str += '<div id="degree_select" class="select" style="width: 130px;">';
			str += '<span style="color:#a2a2a2"><a></a></span><i></i></div>';
			str += '</dd>';

			str += '<dd>';
			str += '<input id="level" name="level[]" type="hidden" value="' + v.level + '">';
			str += '<div id="level_select" class="select" style="width: 130px;">';
			str += '<span style="color:#a2a2a2"><a></a></span><i></i></div>';
			str += '</dd>';

			str += '<dd><i class="del" onclick="delLanguage($(this))"></i></dd>';
			str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
			str += '</dl>';
			mainCon.find('.language').find('form').find('.additions').before(str);

			//等级
			var select1 = mainCon.find('.language').find('form').find('#languageName' + v.id).find("#level").select({
				defaults: null,
				defaultFill: [{"value": v.level, "text": "等级(非必填)"}]
			});

			mainCon.find('.language').find('form').find('#languageName' + v.id).find("#language").select({
				optionData: option_language,
				selected: v.language,
				callback: function(val, text){
					$.ajax({
						url: '/common/two_options',
						dataType: "json",
						data: "selectPid=" + val + "&_token=" + _token + "&sign=language",
						type: "POST",
						success: function(data){
							select1.resetOptions(data);
						},
						error: function(){
							layer.msg('加载错误，可能网络原因引起的错误');
						},
						complete: function(){
						}
					});
				}
			});
			$.ajax({
				url: '/common/two_options',
				dataType: "json",
				data: "selectPid=" + v.language + "&_token=" + _token + "&sign=language",
				type: "POST",
				success: function(data){
					select1.resetOptions(data);
					select1.resetSelected(v.level);//设置选定值
					//ajax加载完成以后显示内容
				},
				error: function(){
					layer.msg('加载错误，可能网络原因引起的错误');
				},
				complete: function(){
				}
			});
			mainCon.find('.language').find('form').find('#languageName' + v.id).find("#degree").select({
					optionData: option_degree, selected: v.degree
				}
			);
		});
	}else{
		addLanguageCate('one');
	}
}
//添加语言选项
function addLanguageOpt(othis, languageid){
	addLanguageCate(languageid);
	var lastIndex = mainCon.find('.language').find('form').find('dl').find('.sList').length;
	if(lastIndex >= 10){
		mainCon.find('.language').find('.additions').hide();
	}
}
//编辑语言能力
function editorLanguage(othis){
	othis.parent('.resumeEdit').hide();
	mainCon.find('.languageCon').hide();
	mainCon.find('.languageInput').show();
	mainCon.find('.language').find('form').find('dl').remove();
	jsonLanguage();
}
//更新赋值语言能力
function updateLanguage(languageArr){
	var languageCon = mainCon.find('.language').find(".languageCon").find('.listItem');
	languageCon.find('ul').remove();
	if(languageArr.length > 0){
		var str = '';
		str += '<ul>';
		$.each(languageArr, function(k, v){
			str += '<li>';
			str += '<strong class="name">' + v.language + '</strong><em>|</em>';
			str += '<span class="degree">';
			str += '<span class="level">' + v.degree + '</span>';
			str += '<em>|</em>';
			str += '<span class="cert">' + v.level + '</span>';
			str += '</span>';
			str += '</li>';
		});
		str += '</ul>';
		languageCon.append(str);
		//添加完成度
		if(mainCon.find('.language').find(".languageCon").find('.listItem').find('li').length > 0){
			completion(6, 1);
		}
	}else{
		completion(6, 0);
	}
}
//添加一项语言能力
function addLanguageCate(languageid){
	var str = '';
	str += '<dl id="addLanguageName' + languageid + '">';
	str += '<div class="sList"></div>';
	str += '<dd>';
	str += '<input id="addLanguage" name="addLanguage[]" type="hidden">';
	str += '<div id="addLanguage_select" class="select" style="width:160px;">';
	str += '<span><a></a></span><i></i></div>';
	str += '</dd>';

	str += '<dd>';
	str += '<input id="addDegree" name="addDegree[]" type="hidden">';
	str += '<div id="addDegree_select" class="select" style="width: 130px;">';
	str += '<span><a></a></span><i></i></div>';
	str += '</dd>';

	str += '<dd>';
	str += '<input id="addLevel" name="addLevel[]" type="hidden">';
	str += '<div id="addLevel_select" class="select" style="width: 130px;">';
	str += '<span style="color:#a2a2a2"><a></a></span><i></i></div>';
	str += '</dd>';

	str += '<dd><i class="del" onclick="delLanguage($(this))"></i></dd>';
	str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
	str += '</dl>';
	//等级
	mainCon.find('.language').find('form').find('.additions').before(str);
	var select1 = mainCon.find('.language').find('form').find('#addLanguageName' + languageid).find("#addLevel").select({
		defaults: null,
		defaultFill: [{"value": '', "text": "等级(非必填)"}]
	});
	mainCon.find('.language').find('form').find('#addLanguageName' + languageid).find("#addLanguage").select({
		optionData: option_language,
		defaults: null,
		defaultFill: [{"value": '', "text": "请选择语种"}],
		callback: function(val, text){
			$.ajax({
				url: '/common/two_options',
				dataType: "json",
				data: "selectPid=" + val + "&_token=" + _token + "&sign=language",
				type: "POST",
				success: function(data){
					select1.resetOptions(data);
				},
				error: function(){
					layer.msg('加载错误，可能网络原因引起的错误');
				},
				complete: function(){

				}
			});
		}
	});
	mainCon.find('.language').find('form').find('#addLanguageName' + languageid).find("#addDegree").select({
			optionData: option_degree, defaults: null, defaultFill: [{"value": '', "text": "选择熟练程度"}]
		}
	);
}
//删除一项语言能力
function delLanguage(othis){
	var index = mainCon.find('.language').find('form').find('dl').find('.sList').length;
	if(index <= 1){
		othis.parents('dl').remove();
		//删除并添加第一个
		addLanguageCate('one');
	}else{
		othis.parents('dl').remove();
	}
	if(index <= 10){
		mainCon.find('.language').find('.additions').show();
	}
}
//保存语言能力
function saveLanguage(othis){
	var lanHid = [];
	var languageArr = [];
	if(mainCon.find('.language').find("input[name='language[]']").length > 0){
		mainCon.find('.language').find("input[name='language[]']").parents('dl').each(function(index){
			languageArr.push($(this).find("input[name='language[]']").val());
			if($(this).find("input[name='language[]']").val() == '' && $(this).find("input[name='degree[]']").val() != ''){
				$(this).find('.errinfo').show().html('语言种类不能为空');
				lanHid.push(1);
			}else if($(this).find("input[name='language[]']").val() != '' && $(this).find("input[name='degree[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择熟练程度');
				lanHid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}
	if(mainCon.find('.language').find("input[name='addLanguage[]']").length > 0){
		mainCon.find('.language').find("input[name='addLanguage[]']").parents('dl').each(function(index){
			if($(this).find("input[name='addLanguage[]']").val() != ''){
				languageArr.push($(this).find("input[name='addLanguage[]']").val());
			}
			if($(this).find("input[name='addLanguage[]']").val() == '' && $(this).find("input[name='addDegree[]']").val() != ''){
				$(this).find('.errinfo').show().html('语言种类不能为空');
				lanHid.push(1);
			}else if($(this).find("input[name='addLanguage[]']").val() != '' && $(this).find("input[name='addDegree[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择熟练程度');
				lanHid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}

	//判断是不是重复添加语言能力
	if(isUnique(languageArr)){
		layer.msg('语言能力不能重复添加！');
	}else{
		if(lanHid.length <= 0){
			var queryString = $('#languageForm').formSerialize();
			$.ajax({
				url: '/personal/add_language',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#languageForm').find('#saveLanguageSub').val('请稍候');
					$('#languageForm').find('#saveLanguageSub').attr('disabled', true);
					$('#languageForm').find('#saveLanguageSub').attr('readonly', true);
				},
				success: function(data){
					othis.parents('.language').find('.resumeEdit').show();
					mainCon.find('.language').find('.languageCon').show();
					mainCon.find('.language').find('.languageInput').hide();
					//判断添加类型
					languageJson = data.json;
					//跟新内容
					updateLanguage(data.arr);
				},
				error: function(data){
					var msgErr = '';
					var errors = $.parseJSON(data.responseText);
					$.each(errors, function(index, value){
						msgErr += value + ";<br>";
					});
					layer.msg(msgErr);
				},
				complete: function(){
					$('#languageForm').find('#saveLanguageSub').val('保存');
					$('#languageForm').find('#saveLanguageSub').removeAttr('disabled');
					$('#languageForm').find('#saveLanguageSub').removeAttr('readonly');
				}
			});
			return false;
		}
	}
}

// -技能专长-------------------------------------------------------------------------------------------------------------------------
//赋值技能专长
function jsonSkill(){
	var skillForm = mainCon.find('#skillForm');
	skillForm.find('#resume_id').val(resumeJson.id);
	if(skillJson.length > 0){
		$.each(skillJson, function(k, v){
			var str = '';
			str += '<dl id="skillName' + v.id + '">';
			str += '<div class="sList"></div>';
			str += '<input name="hidSkillName[]" type="hidden" id="hidSkillName' + v.id + '" value="' + v.skillname + '">';
			str += '<input name="id[]" type="hidden" id="id" value="' + v.id + '">';
			str += '<dd style="margin: 0px; width: 344px;">';
			str += '<span class="jList" style=" width: 342px;">';
			str += '<input type="text" name="skillname[]" id="skillname' + v.id + '" value="' + v.skillname + '" autocomplete="off" style="cursor: text; width: 300px;" placeholder="请输入技能名称"/>';
			str += '<i></i>';
			str += '</span>';
			str += '</dd>';
			str += '<dd>';
			str += '<input id="degree" name="degree[]" type="hidden">';
			str += '<div id="degree_select" class="select" style="width: 130px;">';
			str += '<span style="color:#a2a2a2"><a></a></span><i></i></div>';
			str += '</dd>';
			str += '<dd><i class="del" onclick="delSkill($(this))"></i></dd>';
			str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
			str += '</dl>';
			mainCon.find('.skill').find('form').find('.additions').before(str);
			mainCon.find('.skill').find('form').find('#skillName' + v.id).find("#degree").select({
				optionData: option_degree,
				selected: v.degree,
				defaults: null
			});
			//技能专长选项
			mainCon.find('.skill').find('form').find('#skillName' + v.id).find('.jList i').skill({
				'skillName': "#skillName" + v.id,//显示的ID值
				'hidSkillName': "#hidSkillName" + v.id,//隐藏的ID值
				'skillname': "#skillname" + v.id//inptext文本值
			});
		});
	}else{
		addSkillCate('one');
	}
}
//添加技能选项
function addSkillOpt(othis, skillid){
	addSkillCate(skillid);
	var lastIndex = mainCon.find('.skill').find('form').find('dl').find('.sList').length;
	if(lastIndex >= 10){
		mainCon.find('.skill').find('.additions').hide();
	}
}
//添加一项技能专长
function addSkillCate(skillid){
	var str = '';
	str += '<dl id="addSkillName' + skillid + '">';
	str += '<div class="sList"></div>';
	str += '<input name="addHidSkillName[]" type="hidden" id="addHidSkillName' + skillid + '" value="">';
	str += '<dd style="margin: 0px; width: 344px;">';
	str += '<span class="jList" style=" width: 342px;">';
	str += '<input type="text" name="addskillname[]" id="addskillname' + skillid + '" value="" autocomplete="off" style="cursor: text; width: 300px;" placeholder="请输入技能名称"/>';
	str += '<i></i>';
	str += '</span>';
	str += '</dd>';
	str += '<dd>';
	str += '<input id="degree" name="addDegree[]" type="hidden">';
	str += '<div id="degree_select" class="select" style="width: 130px;">';
	str += '<span style="color:#a2a2a2"><a></a></span><i></i></div>';
	str += '</dd>';
	str += '<dd><i class="del" onclick="delSkill($(this))"></i></dd>';
	str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
	str += '</dl>';
	mainCon.find('.skill').find('form').find('.additions').before(str);
	mainCon.find('.skill').find('form').find('#addSkillName' + skillid).find("#degree").select({
		optionData: option_degree,
		defaults: null,
		defaultFill: [{"value": '', "text": "选择熟练程度"}]
	});
	//技能专长选项
	mainCon.find('.skill').find('form').find('#addSkillName' + skillid).find('.jList i').skill({
		'skillName': "#addSkillName" + skillid,//显示的ID值
		'hidSkillName': "#addHidSkillName" + skillid,//隐藏的ID值
		'skillname': "#addskillname" + skillid//inptext文本值
	});
}
//删除一项技能专长
function delSkill(othis){
	var index = mainCon.find('.skill').find('form').find('dl').find('.sList').length;
	if(index <= 1){
		othis.parents('dl').remove();
		//删除并添加第一个
		addSkillCate('one');
	}else{
		othis.parents('dl').remove();
	}
	if(index <= 10){
		mainCon.find('.skill').find('.additions').show();
	}
}
//更新赋值技能专长
function updateSkill(skillArr){
	var skillCon = mainCon.find('.skill').find(".skillCon").find('.listItem');
	skillCon.find('ul').remove();
	if(skillArr.length > 0){
		var str = '';
		str += '<ul>';
		$.each(skillArr, function(k, v){
			str += '<li>';
			str += '<strong class="name">' + v.skillname + '</strong><em>|</em>';
			str += '<span class="degree">';
			str += '<span class="level">' + v.degree + '</span>';
			str += '</span>';
			str += '</li>';
		});
		str += '</ul>';
		skillCon.append(str);

		//添加完成度
		if(mainCon.find('.skill').find(".skillCon").find('.listItem').find('li').length > 0){
			completion(7, 1);
		}
	}else{
		completion(7, 0);
	}
}
//编辑技能专长
function editorSkill(othis){
	othis.parent('.resumeEdit').hide();
	mainCon.find('.skillCon').hide();
	mainCon.find('.skillInput').show();
	mainCon.find('.skill').find('form').find('dl').remove();
	jsonSkill();
}
//保存技能专长
function saveSkill(othis){
	var hid = [];
	var skillName = [];
	if(mainCon.find('.skill').find("input[name='hidSkillName[]']").length > 0){
		mainCon.find('.skill').find("input[name='hidSkillName[]']").parents('dl').each(function(index){
			skillName.push($(this).find("input[name='skillname[]']").val());
			if($(this).find("input[name='skillname[]']").val() == '' && $(this).find("input[name='degree[]']").val() != ''){
				$(this).find('.errinfo').show().html('技能名称不能为空');
				$(this).find("input[name='skillname[]']").focus();
				hid.push(1);
			}else if($(this).find("input[name='skillname[]']").val() != '' && $(this).find("input[name='degree[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择熟练程度');
				hid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}
	if(mainCon.find('.skill').find("input[name='addHidSkillName[]']").length > 0){
		mainCon.find('.skill').find("input[name='addHidSkillName[]']").parents('dl').each(function(index){
			if($(this).find("input[name='addskillname[]']").val() != ''){
				skillName.push(str_trim($(this).find("input[name='addskillname[]']").val()));
			}
			if($(this).find("input[name='addskillname[]']").val() == '' && $(this).find("input[name='addDegree[]']").val() != ''){
				$(this).find('.errinfo').show().html('技能名称不能为空');
				$(this).find("input[name='addskillname[]']").focus();
				hid.push(1);
			}else if($(this).find("input[name='addskillname[]']").val() != '' && $(this).find("input[name='addDegree[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择熟练程度');
				hid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}
	//判断是不是重复添加技能专长
	if(isUnique(skillName)){
		layer.msg('技能专长不能重复添加！');
	}else{
		if(hid.length > 0){

		}else{
			var queryString = $('#skillForm').formSerialize();
			$.ajax({
				url: '/personal/add_skill',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#skillForm').find('#saveSkillSub').val('请稍候');
					$('#skillForm').find('#saveSkillSub').attr('disabled', true);
					$('#skillForm').find('#saveSkillSub').attr('readonly', true);
				},
				success: function(data){
					othis.parents('.skill').find('.resumeEdit').show();
					mainCon.find('.skill').find('.skillCon').show();
					mainCon.find('.skill').find('.skillInput').hide();
					//判断添加类型
					skillJson = data.json;
					//跟新内容
					updateSkill(data.arr);
				},
				error: function(data){
					var msgErr = '';
					var errors = $.parseJSON(data.responseText);
					$.each(errors, function(index, value){
						msgErr += value + ";<br>";
					});
					layer.msg(msgErr);
				},
				complete: function(){
					$('#skillForm').find('#saveSkillSub').val('保存');
					$('#skillForm').find('#saveSkillSub').removeAttr('disabled');
					$('#skillForm').find('#saveSkillSub').removeAttr('readonly');
				}
			});
			return false;
		}
	}
}

// -证书-------------------------------------------------------------------------------------------------------------------------
//赋值证书
function jsonCertificate(){
	var certificateForm = mainCon.find('#certificateForm');
	certificateForm.find('#resume_id').val(resumeJson.id);
	if(certificateJson.length > 0){
		$.each(certificateJson, function(k, v){
			var str = '';
			str += '<dl id="certificateName' + v.id + '">';
			str += '<div class="sList"></div>';
			str += '<input name="hidCertificateName[]" type="hidden" id="hidCertificateName' + v.id + '" value="' + v.certificate_name + '">';
			str += '<input name="id[]" type="hidden" id="id" value="' + v.id + '">';
			str += '<dd style="margin: 0px; width: 344px;">';
			str += '<span class="jList" style=" width: 342px;">';
			str += '<input type="text" name="certificate_name[]" id="certificate_name' + v.id + '" value="' + v.certificate_name + '" autocomplete="off" style="cursor: text; width: 300px;" placeholder="请输入证书名称"/>';
			str += '<i></i>';
			str += '</span>';
			str += '</dd>';

			str += '<dd>';
			str += '<div class="curgettime showTime" id="curgettime">';
			str += '<input name="gettime[]" id="gettime" type="hidden" value="">';
			str += '</div>';
			str += '</dd>';

			str += '<dd><i class="del" onclick="delCertificate($(this))"></i></dd>';
			str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
			str += '</dl>';
			mainCon.find('.certificate').find('form').find('.additions').before(str);
			//赋值时间
			v.gettime = (v.gettime == '0000-00-00') ? '' : v.gettime;
			certificateForm.find('#certificateName' + v.id).find("#curgettime").find('#gettime').val(v.gettime);
			//证书选项
			mainCon.find('.certificate').find('form').find('#certificateName' + v.id).find('.jList i').certificate({
				'certificateName': "#certificateName" + v.id,//显示的ID值
				'hidCertificateName': "#hidCertificateName" + v.id,//隐藏的ID值
				'certificate_name': "#certificate_name" + v.id//inptext文本值
			});
			//获得证书时间
			mainCon.find('.certificate').find('form').find('#certificateName' + v.id).find("#curgettime").autoTime({
				year: "getYear",                               //弹出层年份
				established: '#gettime'                      //入职时间
			});
		});
	}else{
		addCertificateCate('one');
	}
}
//编辑证书
function editorCertificate(othis){
	othis.parent('.resumeEdit').hide();
	mainCon.find('.certificateCon').hide();
	mainCon.find('.certificateInput').show();
	mainCon.find('.certificate').find('form').find('dl').remove();
	jsonCertificate();
}
//添加证书选项
function addCertificateOpt(certificateid){
	addCertificateCate(certificateid);
	var lastIndex = mainCon.find('.certificate').find('form').find('dl').find('.sList').length;
	if(lastIndex >= 10){
		mainCon.find('.certificate').find('.additions').hide();
	}
}
//删除一项证书
function delCertificate(othis){
	var index = mainCon.find('.certificate').find('form').find('dl').find('.sList').length;
	if(index <= 1){
		othis.parents('dl').remove();
		//删除并添加第一个
		addCertificateCate('one');
	}else{
		othis.parents('dl').remove();
	}
	if(index <= 10){
		mainCon.find('.certificate').find('.additions').show();
	}
}
//添加一项证书
function addCertificateCate(certificateid){
	var str = '';
	str += '<dl id="addCertificateName' + certificateid + '">';
	str += '<div class="sList"></div>';
	str += '<input name="addHidCertificateName[]" type="hidden" id="addHidCertificateName' + certificateid + '" value="">';
	str += '<dd style="margin: 0px; width: 344px;">';
	str += '<span class="jList" style=" width: 342px;">';
	str += '<input type="text" name="addcertificate_name[]" id="addcertificate_name' + certificateid + '" value="" autocomplete="off" style="cursor: text; width: 300px;" placeholder="请输入证书名称"/>';
	str += '<i></i>';
	str += '</span>';
	str += '</dd>';

	str += '<dd>';
	str += '<div class="curgettime showTime" id="curgettime">';
	str += '<input name="addGettime[]" id="gettime" type="hidden" value="">';
	str += '</div>';
	str += '</dd>';

	str += '</dd>';
	str += '<dd><i class="del" onclick="delCertificate($(this))"></i></dd>';
	str += '<dd class="errinfo error" style="display: none; font-family:微软雅黑"></dd>';
	str += '</dl>';
	mainCon.find('.certificate').find('form').find('.additions').before(str);

	//获得证书时间
	mainCon.find('.certificate').find('form').find('#addCertificateName' + certificateid).find("#curgettime").autoTime({
		year: "getYear",                               //弹出层年份
		established: '#gettime'                      //入职时间
	});
	//证书选项
	mainCon.find('.certificate').find('form').find('#addCertificateName' + certificateid).find('.jList i').certificate({
		'certificateName': "#addCertificateName" + certificateid,//显示的ID值
		'hidCertificateName': "#addHidCertificateName" + certificateid,//隐藏的ID值
		'certificate_name': "#addcertificate_name" + certificateid//inptext文本值
	});
}
//更新赋值证书
function updateCertificate(certificateArr){
	var certificateCon = mainCon.find('.certificate').find(".certificateCon").find('.listItem');
	certificateCon.find('ul').remove();
	if(certificateArr.length > 0){
		var str = '';
		str += '<ul>';
		$.each(certificateArr, function(k, v){
			str += '<li>';
			str += '<strong class="name">' + v.certificate_name + '</strong><em>|</em>';
			str += '<span class="degree">';
			str += '<span class="level">' + v.gettime + '年获得</span>';
			str += '</span>';
			str += '</li>';
		});
		str += '</ul>';
		certificateCon.append(str);
		//添加完成度
		if(mainCon.find('.certificate').find(".certificateCon").find('.listItem').find('li').length > 0){
			completion(8, 1);
		}
	}else{
		completion(8, 0);
	}
}
//保存证书
function saveCertificate(othis){
	var cerHid = [];
	var certificateName = [];
	if(mainCon.find('.certificate').find("input[name='hidCertificateName[]']").length > 0){
		mainCon.find('.certificate').find("input[name='hidCertificateName[]']").parents('dl').each(function(index){
			certificateName.push($(this).find("input[name='certificate_name[]']").val());
			if($(this).find("input[name='certificate_name[]']").val() == '' && $(this).find("input[name='gettime[]']").val() != ''){
				$(this).find('.errinfo').show().html('证书名称不能为空');
				$(this).find("input[name='certificate_name[]']").focus();
				cerHid.push(1);
			}else if($(this).find("input[name='certificate_name[]']").val() != '' && $(this).find("input[name='gettime[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择获取年份');
				cerHid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}
	if(mainCon.find('.certificate').find("input[name='addHidCertificateName[]']").length > 0){
		mainCon.find('.certificate').find("input[name='addHidCertificateName[]']").parents('dl').each(function(index){
			if($(this).find("input[name='addcertificate_name[]']").val() != ''){
				certificateName.push(str_trim($(this).find("input[name='addcertificate_name[]']").val()));
			}
			if($(this).find("input[name='addcertificate_name[]']").val() == '' && $(this).find("input[name='addGettime[]']").val() != ''){
				$(this).find('.errinfo').show().html('证书名称不能为空');
				$(this).find("input[name='addcertificate_name[]']").focus();
				cerHid.push(1);
			}else if($(this).find("input[name='addcertificate_name[]']").val() != '' && $(this).find("input[name='addGettime[]']").val() == ''){
				$(this).find('.errinfo').show().html('请选择获取年份');
				cerHid.push(1);
			}else{
				$(this).find('.errinfo').hide();
			}
		});
	}
	//判断是不是重复添加证书
	if(isUnique(certificateName)){
		layer.msg('证书不能重复添加！');
	}else{
		if(cerHid.length <= 0){
			var queryString = $('#certificateForm').formSerialize();
			$.ajax({
				url: '/personal/add_certificate',
				dataType: "json",
				data: queryString,
				type: "POST",
				beforeSend: function(){
					$('#certificateForm').find('#saveCertificateSub').val('请稍候');
					$('#certificateForm').find('#saveCertificateSub').attr('disabled', true);
					$('#certificateForm').find('#saveCertificateSub').attr('readonly', true);
				},
				success: function(data){
					othis.parents('.certificate').find('.resumeEdit').show();
					mainCon.find('.certificate').find('.certificateCon').show();
					mainCon.find('.certificate').find('.certificateInput').hide();
					//赋值内容
					certificateJson = data.json;
					//跟新内容
					updateCertificate(data.arr);
				},
				error: function(data){
					var msgErr = '';
					var errors = $.parseJSON(data.responseText);
					$.each(errors, function(index, value){
						msgErr += value + ";<br>";
					});
					layer.msg(msgErr);
				},
				complete: function(){
					$('#certificateForm').find('#saveCertificateSub').val('保存');
					$('#certificateForm').find('#saveCertificateSub').removeAttr('disabled');
					$('#certificateForm').find('#saveCertificateSub').removeAttr('readonly');
				}
			});
			return false;
		}
	}
}

// -其它信息-------------------------------------------------------------------------------------------------------------------------
//添加其它信息
function addOther(othis, otype){
	othis.parents('.other').find('.resumeAdd').hide();
	var otherCon = mainCon.find('.other').find('.otherCon');
	otherCon.find('.otherInput').remove();
	otherCon.find('.other').remove();
	otherCon.find('.listCon').show();
	otherCon.prepend(otherInput);
	otherCon.find('.otherInput').css({'margin-top': '0'}).show();
	if(otype == 'add') otherCon.find('.otherInput .sAdd').show();
	selectOther = mainCon.find('.other').find("#title").select({
		optionData: option_title, defaults: null,
		callback: function(val, text){
			if(val == 'zdy'){
				if(mainCon.find('.other').find("#title").parents('dl').find("#titZdy").length <= 0){
					var str = '';
					str += '<dd id="titZdy"><input id="titInp" name="titInp" type="text" placeholder="请输入主题名称" style="width: 220px;"></dd>';
					mainCon.find('.other').find("#title").parents('dd').after(str);
				}
			}else{
				if(mainCon.find('.other').find("#title").parents('dl').find("#titZdy").length > 0){
					mainCon.find('.other').find("#title").parents('dl').find("#titZdy").remove();
				}
			}
		}
	});
	//检查表单内容
	checkOtherInp(othis, 'add', '');
}
//检查表单内容
function checkOtherInp(othis, otype, titleVal){
	//个人简历自我评价验证 使用jQuery Validate 插件进行验证
	$.validator.addMethod("checkTitle", function(value, element, param){
		var param1 = param[0];
		if(otherJson.length > 0){
			var otherArr = [];
			$.each(otherJson, function(k, v){
				otherArr[k] = v.title;
			});
		}
		if(value == 'zdy'){
			var titInp = mainCon.find('.other').find("#title").parents('dl').find("#titZdy").find('#titInp').val();
			if(titInp == ''){
				mainCon.find('.other').find("#title").parents('dl').find("#titZdy").find('#titInp').focus();
				return false;
			}else{
				if(in_array(titInp, otherArr) && titInp != param1){
					layer.msg('主题的附加信息已经存在，请重新填写！', {time: 2000});
					return false;
				}else{
					return true;
				}
			}
		}else{
			var titleVal = mainCon.find('.other').find("#title_select").find("span a").html();
			if(in_array(titleVal, otherArr) && titleVal != param1){
				layer.msg('主题的附加信息已经存在，请重新选择！', {time: 2000});
				return false;
			}else{
				return true;
			}
		}
	}, '请选择附加主题！');

	$('#otherForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			title: {
				required: true,
				checkTitle: [titleVal]
			},
			content: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			title: {
				required: "请选择个性特长"
			},
			content: {
				required: "内容描述不能为空"
			}
		},
		submitHandler: function(form){
			var queryString = $('#otherForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_other',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#otherForm').find('#saveOther').val('请稍候');
						$('#otherForm').find('#saveOther').attr('disabled', true);
						$('#otherForm').find('#saveOther').attr('readonly', true);
					},
					success: function(data){
						//判断添加类型
						otherCancel(othis);
						//跟新内容
						updateOther(data.arr);
						appendOtherJson = data.json;
						otherJson = data.newJson;
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#otherForm').find('#saveOther').val('保存');
						$('#otherForm').find('#saveOther').removeAttr('disabled');
						$('#otherForm').find('#saveOther').removeAttr('readonly');
					}
				});
			}else{
				if(mainCon.find('.other').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_other',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#otherForm').find('#saveOther').val('请稍候');
							$('#otherForm').find('#saveOther').attr('disabled', true);
							$('#otherForm').find('#saveOther').attr('readonly', true);
						},
						success: function(data){
							//跟新内容
							appendOther(data.arr);
							appendOtherJson = data.json;
							otherJson = data.newJson;
							//判断添加类型
							otherCancel(othis);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#otherForm').find('#saveOther').val('保存');
							$('#otherForm').find('#saveOther').removeAttr('disabled');
							$('#otherForm').find('#saveOther').removeAttr('readonly');
						}
					});
				}else if(mainCon.find('.other').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_other',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#otherForm').find('#addSaveOther').val('请稍候');
							$('#otherForm').find('#addSaveOther').attr('disabled', true);
							$('#otherForm').find('#addSaveOther').attr('readonly', true);
						},
						success: function(data){
							addOther(othis, otype);
							//更新内容
							appendOther(data.arr);
							appendOtherJson = data.json;
							otherJson = data.newJson;
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){
							$('#otherForm').find('#addSaveOther').val('保存并添加');
							$('#otherForm').find('#addSaveOther').removeAttr('disabled');
							$('#otherForm').find('#addSaveOther').removeAttr('readonly');
						}
					});
				}
			}
		}
	});
}
//追加其它信息
function appendOther(other){
	//添加完成度
	if(mainCon.find('.other').find('.otherCon').find('.listCon').length <= 0){
		completion(9, 1);
	}
	var str = '';
	str += '<div class="listCon" id="listCon' + other.id + '">';
	str += '<div class="listLeft"><span class="listTime otherTit">' + mSubstr(other.title, 14) + '</span></div>';
	str += '<div class="listCenter">';
	str += '<div class="tit titOther" style="position: absolute; width: 0px;"></div>';
	str += '<div class="info" style="padding:3px 37px 30px 25px;"><p>' + nl2br(other.content) + '</p></div>';
	str += '</div>';
	str += '<div class="listRight">';
	str += '<span class="edit"><input onclick="editOther($(this),\'' + other.id + '\')" name="" value="编辑" type="button"></span>';
	str += '<span class="del"><input onclick="delOther(\'' + other.id + '\')" name="" value="删除" type="button"></span>';
	str += '</div>';
	str += '</div>';
	mainCon.find('.other').find('.otherCon').find('.otherInput').after(str);
}
//编辑其它信息
function editOther(othis, id){
	var selected;
	//表单赋值
	$.ajax({
		url: '/personal/edit_other',
		dataType: "json",
		data: "id=" + id + "&_token=" + _token,
		type: "POST",
		success: function(data){
			othis.parents('.other').find('.resumeAdd').show();
			mainCon.find('.other').find('.otherCon').find('.otherInput').remove();
			othis.parents('#listCon' + id).after(otherInput);
			mainCon.find('.other').find('.otherCon').find('.otherInput').show();

			var otherForm = mainCon.find('.other').find('#otherForm');
			otherForm.find('#id').val(data.id);
			//设置个性特长
			switch(data.title){
				case '兴趣爱好':
					selected = 1;
					break;
				case '宗教信仰':
					selected = 2;
					break;
				case '职业目标':
					selected = 3;
					break;
				case '获奖荣誉':
					selected = 4;
					break;
				case '个性特长':
					selected = 5;
					break;
				default:
					selected = 'zdy';
			}
			otherForm.find("#title").select({
					optionData: option_title, selected: selected, defaults: null,
					callback: function(val, text){
						if(val == 'zdy'){
							if(mainCon.find('.other').find("#title").parents('dl').find("#titZdy").length <= 0){
								var str = '';
								str += '<dd id="titZdy"><input id="titInp" name="titInp" type="text" placeholder="请输入主题名称" style="width: 220px;"></dd>';
								mainCon.find('.other').find("#title").parents('dd').after(str);
							}
						}else{
							if(mainCon.find('.other').find("#title").parents('dl').find("#titZdy").length > 0){
								mainCon.find('.other').find("#title").parents('dl').find("#titZdy").remove();
							}
						}
					}
				}
			);

			if(selected == 'zdy'){
				var str = '';
				str += '<dd id="titZdy"><input id="titInp" name="titInp" type="text" placeholder="请输入主题名称" value="' + data.title + '" style="width: 220px;"></dd>';
				mainCon.find('.other').find("#title").parents('dd').after(str);
			}

			otherForm.find("#content").html(data.content);
			mainCon.find('.other').find('.otherCon').find('.listCon').each(function(){
				$(this).parents('.otherCon').find('#listCon' + id).hide().siblings().show();
			});
			//检查表单内容
			checkOtherInp(othis, 'mod', data.title);
		},
		error: function(data){
			layer.msg('可能网络原因引起的错误');
		},
		complete: function(){

		}
	});
}
//更新其它信息
function updateOther(updateOther){
	var OtherCon = mainCon.find('.otherCon').find("#listCon" + updateOther.id);
	OtherCon.find('.otherTit').html(mSubstr(updateOther.title, 12));
	OtherCon.find('.info').html(nl2br(updateOther.content));
}
//取消其它信息
function otherCancel(othis){
	othis.parents('.other').find('.resumeAdd').show();
	mainCon.find('.other').find('.otherInput').remove();
	mainCon.find('.other').find('.otherCon').find('.listCon').show();
}
//删除其它信息
function delOther(id){
	layer.confirm('您确定要删除这个附加信息吗？', {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.post("/personal/del_other", {
			'id': id,
			'_token': _token
		}, function(data){
			if(data.status == 0){
				layer.msg(data.msg, {icon: 6, time: 1000});
				mainCon.find('.other').find('.otherCon').find('#listCon' + id).remove();
				//添加完成度
				if(mainCon.find('.other').find('.otherCon').find('.listCon').length <= 0){
					completion(9, 0);
				}
			}else{
				layer.msg(data.msg, {icon: 5, time: 1500});
			}
		});
	}, function(){

	});
}
//判断类型
function otherType(type){
	mainCon.find('.other').find("#otype").val(type);
}

// -我的作品-------------------------------------------------------------------------------------------------------------------------
//添加我的作品
function addWorks(othis, otype){
	othis.parents('.works').find('.resumeUpload').hide();
	mainCon.find('.works').find('.worksCon').find('.listCon li').show();
	var worksCon = mainCon.find('.works').find('.worksCon');
	worksCon.find('.worksInput').remove();
	worksCon.find('.worksFile').remove();
	worksCon.find('.listCon').show();
	worksCon.prepend(worksInput);
	worksCon.find('.worksInput').css({'margin-top': '0'}).show();
	if(otype == 'add') worksCon.find('.worksInput .sAdd').show();
	//上传文件
	uploaderFile(5);
	//检查表单内容
	checkWorksInp(othis, 'add');
}
//上传文件
function uploaderFile(fileNum){
	uploader = WebUploader.create({
		auto: false,
		formData: {
			_token: _token
		},
		multiple: true,  //开启多个文件上传
		// swf文件路径
		swf: BASE_URL + 'vendor/webuploader/dist/Uploader.swf',
		// 文件接收服务端。
		server: '/personal/fileupload',
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#picker',
		//duplicate :true,
		compress: {
			//width: 200,
			// height: 400,
			// 图片质量，只有type为`image/jpeg`的时候才有效。
			//quality: 100,
			// 是否允许放大，如果想要生成小图的时候不失真，此选项应该设置为false.
			allowMagnify: true,
			// 是否允许裁剪。
			crop: true,
			compressSize: 0,
			noCompressIfLarger: false
		},

		fileNumLimit: fileNum,
		fileSingleSizeLimit: 2000 * 1024,
		accept: {
			title: 'intoTypes',
			extensions: 'doc,docx,xls,xlsx,pdf,ppt,pptx,txt,gif,jpg,jpeg,bmp,png',
			mimeTypes: '.doc,.xls,.docx,.xlsx,.pdf,.ppt,.pptx,.txt,.gif,.jpg,.jpeg,.bmp,.png*'
		}
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		// resize: true
	});
	//上传文件出错时
	uploader.on('error', function(file){
		if(file == 'F_EXCEED_SIZE'){
			layer.msg('文件上传大小不能超过2M！');
		}
		if(file == 'F_DUPLICATE'){
			layer.msg('此文件已经存在队列当中，不能重复上传！');
		}
		if(file == 'Q_EXCEED_NUM_LIMIT'){
			layer.msg('文件上传个数最多不能超过5个！');
		}
		if(file == 'Q_TYPE_DENIED'){
			layer.msg('文件上传的类型不匹配，请重新上传！');
		}
	});
	// 当有文件被添加进队列的时候
	uploader.on('fileQueued', function(file){
		var str = '';
		str += '<div id="' + file.id + '" class="item">';
		str += '<i class="imgIcon"></i>';
		str += '<span class="imgInfo">' + mSubstr(file.name, 30)  + '</span>';
		str += '<i class="delIcon"></i>';
		str += '</div>';
		mainCon.find('.works').find("dl#uploader").find('dd').prepend(str);
		//删除上传文件
		mainCon.find('.works').find("dl#uploader").find('dd').find("#" + file.id).on('click', '.delIcon', function(){
			mainCon.find('.works').find("dl#uploader").find('dd').find("#" + file.id).remove();
			uploader.removeFile(file.id, true);
		});
	});

	//上传文件成功时
	uploader.on('uploadSuccess', function(file, response){
		if(response.status == 200){
			fileUrlImg.push(response.fileUrlImg);
			fileCon.push(response.fileCon);

			//文件后缀名
			var suffix = response.fileCon.substring(response.fileCon.lastIndexOf('.') + 1);
			if(in_array(suffix, ['gif', 'jpg', 'jpeg', 'bmp', 'png'])){
				imgurl = response.fileCon;
			}else{
				switch(suffix){
					case 'doc' :
						imgurl = asset + 'default/images/personal/doc.jpg';
						break;
					case 'docx' :
						imgurl = asset + 'default/images/personal/doc.jpg';
						break;
					case 'ppt' :
						imgurl = asset + 'default/images/personal/ppt.jpg';
						break;
					case 'pptx' :
						imgurl = asset + 'default/images/personal/ppt.jpg';
						break;
					case 'xls' :
						imgurl = asset + 'default/images/personal/xls.jpg';
						break;
					case 'xlsx' :
						imgurl = asset + 'default/images/personal/xls.jpg';
						break;
					case 'pdf' :
						imgurl = asset + 'default/images/personal/pdf.jpg';
						break;
					case 'txt' :
						imgurl = asset + 'default/images/personal/txt.jpg';
						break;
					default :
						imgurl = '未知';
						break;
				}
			}
			photoJson[response.works_id].push({
				"alt": "<a target='_blank' href='" + response.fileCon + "'>下载源文件</a>",
				"pid": file.id, //图片id
				"src": imgurl, //原图地址
				"thumb": imgurl //缩略图地址
			});

		}else{
			layer.msg(response.info);
		}
	});
	//当文件上传结束以后调用
	uploader.on('uploadFinished', function(){
		//添加完成度
		if(mainCon.find('.works').find('.worksCon').find('.listCon').find('li').length <= 0){
			completion(10, 1);
		}
		//追加我的作品
		if(mainCon.find('.works').find('.worksCon').find('.listCon').find('ul').find('#liCon' + appendWorksJson.id).length <= 0){
			var str = '';
			str += '<li id="liCon' + appendWorksJson.id + '">';
			str += '<div class="workImg">';
			str += '<span class="img"><a><img src="' + fileUrlImg[0] + '"></a></span>';
			str += '<span class="imgTit"><a>' + appendWorksJson.works_name + '</a></span>';
			str += '</div>';
			str += '<div class="operating">';
			str += '<span><a onclick="editWorks($(this),' + appendWorksJson.id + ')">编辑</a> </span>';
			str += '<span><a onclick="delWorks(' + appendWorksJson.id + ')">删除</a> </span>';
			str += '</div>';
			str += '</li>';
			mainCon.find('.works').find('.worksCon').find('.listCon').find('ul').prepend(str);
			mainCon.find('.works').find('.worksCon').find('.listCon').find('#liCon' + appendWorksJson.id).find('.workImg').click(function(){
				rotateImg(photoJson[appendWorksJson.id]);
			});
		}
		updateWorks();
		//添加隐藏
		if(!ptype){
			worksCancel();
		}
	});
}
//轮播图片
function rotateImg(photoJson){
	layer.photos({
		photos: {
			"title": '', //相册标题
			"id": '', //相册id
			"start": 0, //初始显示的图片序号，默认0
			"data": photoJson
		},
		//显示关闭按钮
		closeBtn: 2,
		area: 'auto',
		//设置最大宽度
		maxWidth: '700',
		//是否显示拖拽
		move: false,
		//设置图片信息
		tab: function(pic, layero){
			//console.log(pic) //当前图片的一些信息
			$('.layui-layer-content').css({'border': '1px solid #444', 'padding': '10px'});
		}
		, shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
	});
}
//检查表单内容
function checkWorksInp(othis, otype){
	//个人简历我的作品验证 使用jQuery Validate 插件进行验证
	$('#worksForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			works_name: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			works_name: {
				required: "请输入项目名称"
			}
		},
		submitHandler: function(form){
			//判断文件是不是上传
			var fileLength = mainCon.find('.works').find("#uploader").find('dd').find('.item').length;
			if(fileLength == 0){
				layer.msg('请添加作品附件!', {time: 1500});
				return false;
			}
			var queryString = $('#worksForm').formSerialize();
			//判断是不是修改
			if(otype == 'mod'){
				$.ajax({
					url: '/personal/mod_works',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#worksForm').find('#saveWorks').val('请稍候');
						$('#worksForm').find('#saveWorks').attr('disabled', true);
						$('#worksForm').find('#saveWorks').attr('readonly', true);
					},
					success: function(data){
						ptype = false;
						//清空内容
						fileUrlImg = [];
						fileCon = [];
						photoJson[data.id] = [];
						appendWorksJson = data;
						if(data.allfile != ''){
							$.each(data.allfile, function(k, v){
								fileUrlImg.push(v.fileUrlImg);
								fileCon.push(v.fileCon);
								photoJson[data.id].push({
									"alt": "<a target='_blank' href='" + v.fileCon + "'>查看附件</a>",
									"pid": appendWorksJson.id, //图片id
									"src": v.fileUrlImg, //原图地址
									"thumb": v.fileUrlImg //缩略图地址
								});
							});
						}
						if(uploader.getFiles() != ''){
							uploader.option('formData', {
								works_id: data.id,
								resume_id: data.resume_id
							});
							uploader.upload();
						}else{
							updateWorks();
							worksCancel();
						}
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
					}
				});
			}else{
				if(mainCon.find('.works').find("#otype").val() == '1'){
					$.ajax({
						url: '/personal/add_works',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#worksForm').find('#saveWorks').val('请稍候');
							$('#worksForm').find('#saveWorks').attr('disabled', true);
							$('#worksForm').find('#saveWorks').attr('readonly', true);
						},
						success: function(data){
							ptype = false;
							fileUrlImg = [];//作品上传
							fileCon = [];//作品上传
							photoJson[data.id] = [];
							//console.log(photoJson);
							//更新内容
							appendWorksJson = data;
							uploader.option('formData', {
								works_id: data.id,
								resume_id: data.resume_id
							});
							uploader.upload();
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){

						}
					});
				}else if(mainCon.find('.works').find("#otype").val() == '2'){
					$.ajax({
						url: '/personal/add_works',
						dataType: "json",
						data: queryString,
						type: "POST",
						beforeSend: function(){
							$('#worksForm').find('#addSaveWorks').val('请稍候');
							$('#worksForm').find('#addSaveWorks').attr('disabled', true);
							$('#worksForm').find('#addSaveWorks').attr('readonly', true);
						},
						success: function(data){
							//更新内容
							fileUrlImg = [];//作品上传
							fileCon = [];//作品上传
							ptype = true;
							photoJson[data.id] = [];
							appendWorksJson = data;
							uploader.option('formData', {
								works_id: data.id,
								resume_id: data.resume_id
							});
							uploader.upload();
							mainCon.find('.works').find('worksCon').find('.worksInput').remove();
							addWorks(othis, otype);
						},
						error: function(data){
							var msgErr = '';
							var errors = $.parseJSON(data.responseText);
							$.each(errors, function(index, value){
								msgErr += value + ";<br>";
							});
							layer.msg(msgErr);
						},
						complete: function(){

						}
					});
				}
			}

		}
	});
}
//编辑我的作品
function editWorks(othis, id){
	//表单赋值
	$.ajax({
		url: '/personal/edit_works',
		dataType: "json",
		data: "id=" + id + "&_token=" + _token,
		type: "POST",
		success: function(data){
			othis.parents('.works').find('.resumeUpload').show();
			mainCon.find('.works').find('.worksCon').find('.worksInput').remove();
			othis.parents('#liCon' + id).hide().siblings().show();
			othis.parents('.worksCon').prepend(worksInput);
			mainCon.find('.works').find('.worksCon').find('.worksInput').show();
			mainCon.find('.works').find('.worksCon').find('.worksInput').css({'margin-top': 0});

			var worksForm = mainCon.find('.works').find('#worksForm');
			worksForm.find('#id').val(data.id);
			worksForm.find('#works_name').val(data.works_name);
			worksForm.find('#description').val(data.description);
			//判断有没上传文件
			if(data.allfile == undefined || data.allfile == ''){
				//上传文件
				uploaderFile(5);
			}else{
				$.each(data.allfile, function(k, v){
					var str = '';
					str += '<div id="file' + v.id + '" class="item">';
					str += '<input name="w_id[]" value="' + v.id + '" type="hidden">';
					str += '<i class="imgIcon"></i>';
					str += '<span class="imgInfo">' +  mSubstr(v.originalimg, 30) + '</span>';
					str += '<i class="delIcon"></i>';
					str += '</div>';
					mainCon.find('.works').find("dl#uploader").find('dd').prepend(str);
					//删除上传文件
					mainCon.find('.works').find("dl#uploader").find('dd').find("#file" + v.id).find('.delIcon').click(function(){
						$(this).parents("#file" + v.id).remove();
						var fNumber = 5 - mainCon.find('.works').find('.worksCon').find('.worksInput').find('#uploader').find('.item').length;
						uploaderFile(fNumber);
					});
				});
			}


			var fNum = mainCon.find('.works').find('.worksCon').find('.worksInput').find('#uploader').find('.item').length;
			//文件上传个数
			var fNumber = (5 - fNum == 0) ? -1 : 5 - fNum;
			//上传文件
			uploaderFile(fNumber);

			//检查表单内容
			checkWorksInp(othis, 'mod');
		},
		error: function(data){
			layer.msg('可能网络原因引起的错误');
		},
		complete: function(){

		}
	});
}
//更新我的作品
function updateWorks(){
	//alert(3333)
	var WorksCon = mainCon.find('.worksCon').find('.listCon').find("#liCon" + appendWorksJson.id);
	WorksCon.find('.img a').find('img').attr('src', fileUrlImg[0]);
	WorksCon.find('.imgTit a').html(mSubstr(appendWorksJson.works_name, 22));
}
//取消我的作品
function worksCancel(){
	mainCon.find('.works').find('.resumeUpload').show();
	mainCon.find('.works').find('.worksInput').remove();
	mainCon.find('.works').find('.worksCon').find('.listCon').find('li').show();
	mainCon.find('.works').find('#saveWorks').val('保存');
	mainCon.find('.works').find('#saveWorks').removeAttr('disabled');
	mainCon.find('.works').find('#saveWorks').removeAttr('readonly');
}
//删除我的作品
function delWorks(id){
	layer.confirm('您确定要删除这个我的作品吗？', {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.post("/personal/del_works", {
			'id': id,
			'_token': _token
		}, function(data){
			if(data.status == 0){
				layer.msg(data.msg, {icon: 6, time: 1000});
				mainCon.find('.works').find('.worksCon').find('.listCon ul').find('#liCon' + id).remove();
				//添加完成度
				if(mainCon.find('.works').find('.worksCon').find('.listCon').find('li').length <= 0){
					completion(10, 0);
				}
			}else{
				layer.msg(data.msg, {icon: 5, time: 1500});
			}
		});
	}, function(){

	});
}
//判断类型
function worksType(type){
	mainCon.find('.works').find("#otype").val(type);
}

// -取消按钮-------------------------------------------------------------------------------------------------------------------------
/**
 * $para : objCon 加载前
 * $para : objInput 加载后
 * */

function cancel(objCon, objInput, othis){
	mainCon.find(objCon).show();
	mainCon.find(objInput).hide();
	othis.parents('.resumeMange').find('.resumeEdit').show();
}
